﻿<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Gramos - 管理员</title>

    <!-- begin::global styles -->
    <link rel="stylesheet" href="assets/vendors/bundle.css" type="text/css">
    <!-- end::global styles -->

    <!-- begin::custom styles -->
    <link rel="stylesheet" href="assets/css/app.css" type="text/css">
    <!-- end::custom styles -->

</head>
<body class="bg-white h-100-vh p-t-0">

<!-- begin::page loader-->
<div class="page-loader">
    <div class="spinner-border"></div>
    <span>Loading ...</span>
</div>
<!-- end::page loader -->

<div class="p-b-50 d-block d-lg-none"></div>

<div class="container h-100-vh">
    <div class="row align-items-md-center h-100-vh">
        <div class="col-lg-6 d-none d-lg-block">
            <img class="img-fluid" src="assets/media/svg/recover-password.svg" alt="...">
        </div>
        <div class="col-lg-4 offset-lg-1">
            <h3>修改密码</h3>
            <p>现在正在更改密码...</p>
            <form id="updatepassword">
                <div class="form-group mb-4">
                    <input type="text" id="updatepasswordname" name="name" class="form-control fodrm-control-lg" autofocus placeholder="输入用户名">
                    <p style="color:red;" id="error1"></p>
                </div>
                <div class="form-group mb-4">
                    <input type="password" name="password" class="form-control fodrm-control-lg" autofocus placeholder="输入密码">
                    <p style="color:red;" id="error2"></p>
                </div>
                <div class="form-group mb-4">
                    <input type="password" name="repassword" class="form-control fodrm-control-lg" autofocus placeholder="再次确认密码">
                    <p style="color:red;" id="error3"></p>
                </div>
                <button type="button" onclick="doupdatepassword()" class="btn btn-primary btn-lg btn-block btn-uppercase mb-4">修改</button>
                <p class="text-right">
                    <a href="login" class="text-underline">返回登录</a>
                </p>
            </form>
        </div>
    </div>
</div>

<!-- begin::global scripts -->
<script src="assets/vendors/bundle.js"></script>
<!-- end::global scripts -->

<!-- begin::custom scripts -->
<script src="assets/js/app.js"></script>
<!-- end::custom scripts -->

<!-- begin::pagestotransmitdata scripts -->
<script src="assets/js/pagestotransmitdata.js"></script>
<!-- end::pagestotransmitdata scripts -->

<script>

    function doupdatepassword() {
        var data = new FormData(document.getElementById('updatepassword'));
        console.log(data);
        $.ajax({
            url: 'doupdatepassword',
            type: 'post',//请求方式
            data: data,//入参数据

            //对于文件传输设置的属性键值对
            cache:false,//缓存判断
            processData:false,//
            contentType:false,//

            success:function (result){
                console.log(result);
                if(result.isok == true){
                    alert(result.message);
                    location.href = 'login';
                } else {//修改失败
                    if (result.error1 != null && result.error1 != "") document.getElementById('error1').innerText=result.error1;
                    if (result.error2 != null && result.error1 != "") document.getElementById('error2').innerText=result.error2;
                    if (result.error3 != null && result.error1 != "") document.getElementById('error3').innerText=result.error3;
                    if (result.error4 != null && result.error1 != "") document.getElementById('error4').innerText=result.error4;
                }
            },
            error:function () {
                document.getElementById('error4').innerText="系统繁忙修改失败";
            }
        });

    }
</script>

</body>
</html>
